<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>颜色切换示例</title>
    <style>
        /* 简单的样式美化 */
        body {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 20px;
            padding: 50px;
            font-family: Arial, sans-serif;
        }
        #colorText {
            font-size: 24px;
            transition: color 0.3s; /* 添加颜色过渡效果 */
        }
        button {
            padding: 8px 20px;
            cursor: pointer;
        }
        select {
            padding: 5px;
            width: 120px;
        }
    </style>
</head>
<body>
    <select id="colorSelect">
        <option value="red">红</option>
        <option value="yellow">黄</option>
        <option value="blue">蓝</option>
    </select>

    <button id="confirmButton">确定</button>
    
    <p id="colorText">点击确定改变文字颜色</p>

    <script>
        // 获取页面元素
        const colorSelect = document.getElementById('colorSelect');
        const confirmButton = document.getElementById('confirmButton');
        const colorText = document.getElementById('colorText');

        // 按钮点击事件处理
        confirmButton.addEventListener('click', () => {
            // 获取选中的颜色值并应用
            const selectedColor = colorSelect.value;
            colorText.style.color = selectedColor;
        });
    </script>
</body>
</html>